"use strict";
/**
 * @name updateRole
 * 更新角色信息
 */

/**
 * @name getLevelReward
 * 获取玩家升级奖励
 */
exports.getLevelReward = async function () {
	this.updater.role.key('lv');
	this.updater.role.key('lReward');
	await this.updater.data();
	let lv = this.updater.role.get('lv') || 1;
	let lReward = this.updater.role.get('lReward') || 0;
	if (lv == lReward) {
		return;
	}
	let playerConfig = this.config('playerExp');
	for (let k in playerConfig) {
		if (playerConfig[k].lv <= lv && playerConfig[k].lv > lReward) {
			this.updater.item.add(playerConfig[k].levelBonus, 1);
		}
	}
	this.updater.role.set("lReward", lv);
	return this.updater.save();
};